package com.hsgene.order.constants;

/**
 * 支付方式枚举
 *
 * @author wangbing
 * @version 1.0, 2018/8/3
 */
public enum PayType {

    /**
     * 支付方式
     */
    ALIPAY(1, "alipay", "支付宝"),

    WECHAT(2, "wechat", "微信"),

    UNIONPAY(3, "unionpay", "银联"),

    @Deprecated
    UNDEFINED(99, "undefined", "未定义的支付方式"),

    OTHERPAY(98, "otherpay", "其他支付"),

    UNDERLINE_PAY(97, "underline_pay", "线下收款"),

    CHINAUMS_QR(4, "CHINAUMS_QR", "江苏银行扫码付"),

    WX_NATIVE(5, "WX_NATIVE", "微信扫码"),

    WX_JSAPI(6, "WX_JSAPI", "微信公众号或微信小程序"),

    WX_APP(7, "WX_APP", "微信APP"),

    WX_MWEB(8, "WX_MWEB", "微信H5"),

    ALIPAY_WAP(9, "ALIPAY_WAP", "支付宝手机支付"),

    ALIPAY_PC(10, "ALIPAY_PC", "支付宝网站支付"),

    ALIPAY_MOBILE(11, "ALIPAY_MOBILE", "支付宝移动支付");

    private final int value;

    /**
     * 编码
     */
    private final String code;

    /**
     * 描述
     */
    private final String desc;

    public static PayType getEnum(String code) {
        for (PayType type : values()) {
            if (type.code.equalsIgnoreCase(code)) {
                return type;
            }
        }

        throw new IllegalStateException("不支持的支付方式：" + code);
    }

    public static PayType getEnum(int value) {
        for (PayType type : values()) {
            if (type.value == value) {
                return type;
            }
        }

        throw new IllegalStateException("不支持的支付方式：" + value);
    }

    PayType(int value, String code, String desc) {
        this.value = value;
        this.code = code;
        this.desc = desc;
    }

    public int getValue() {

        return value;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
